# Contributor: Thomas Boerger <thomas@webhippie.de>
# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Thomas Boerger <thomas@webhippie.de>
pkgname=hugo
pkgver=0.101.0
pkgrel=0
pkgdesc="Fast and flexible static site generator written in Go"
url="https://gohugo.io/"
license="Apache-2.0"
arch="all"
makedepends="go"
checkdepends="py3-docutils"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
"
source="https://github.com/gohugoio/hugo/archive/v$pkgver/hugo-$pkgver.tar.gz
	skip-git-tests.patch
	skip-para-test.patch
	skip-image-test.patch
	"


# npm is not available on riscv64
if [ "$CARCH" != "riscv64" ]; then
	checkdepends="$checkdepends npm"
fi

build() {
	go build -v -o bin/$pkgname --tags extended
	./bin/hugo gen man
	./bin/hugo completion bash > hugo.bash
	./bin/hugo completion fish > hugo.fish
	./bin/hugo completion zsh > hugo.zsh
}

check() {
	go test ./...
}

package() {
	install -Dm755 bin/$pkgname "$pkgdir"/usr/bin/$pkgname
	install -Dm644 man/*.1 -t "$pkgdir"/usr/share/man/man1

	install -Dm644 hugo.bash \
		"$pkgdir"/usr/share/bash-completion/completions/hugo
	install -Dm644 hugo.fish \
		"$pkgdir"/usr/share/fish/completions/hugo.fish
	install -Dm644 hugo.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_hugo
}

sha512sums="
541d0e04e868845119f2b488fd53b92929ea4dc08685d438a2914b41586e204588b193522013e8eed908dc0c3fbc2714aefb1afad0beae875d57d71aadc59c70  hugo-0.101.0.tar.gz
f07d458b5df72d0b10e0fd9ec6120502b62af1ee347f0ec83eda99147c525327c0098150db80450da48c5bc03d825279e35f0940dae5d909203757abb6bd1a20  skip-git-tests.patch
6ba192d8cb67f115f7ce596c297a55fc64713a4cdb0077cfbb7e45051c7560f5b668da88f513d4f34d8e0eeb4a9d991c5312d62e454c85e95960d8a33f0f8f69  skip-para-test.patch
0feb0495f03315c9224b301ea955061fcbbf9ae8f871640fbb4b5c0792785a714f3a030f702a1f1f6a8048d60f07a133df4ced2a989df0b9c851b8503b59d26d  skip-image-test.patch
"
